#include <iostream>
#include <queue>
#include <vector>
#include <math.h>

using namespace std;

class Point {
public:
    Point(int ix = 0, int iy = 0)
            : _ix(ix), _iy(iy) {
    }

    ~Point() {
    }

    double getDistance() const {
        return hypot(_ix, _iy);
    }

    int getX() const {
        return _ix;
    }

    int getY() const {
        return _iy;
    }

    friend std::ostream &operator<<(std::ostream &os, const Point &rhs);

    friend bool operator==(const Point &lhs, const Point
    &rhs);//std::equal_to
    friend class ComparePoint;

private:
    int _ix;
    int _iy;
};

std::ostream &operator<<(std::ostream &os, const Point &rhs) {
    os << "(" << rhs._ix
       << ", " << rhs._iy
       << ")";
    return os;
}

namespace std {
    template<>
    struct less<Point> {
        bool operator()(const Point &lhs, const Point &rhs) {
//      具体的实现方式可以参考关联式容器中的写法
            return lhs.getX() < rhs.getX();
        }
    };
}

void test1() {
    vector<int> vec = {3, 2, 4, 5, 6, 6, 7, 8, 4, 3};
    priority_queue<int> queue(vec.begin(), vec.end());

    while (!queue.empty()) {
        cout << queue.top() << endl;
        queue.pop();
    }

}


void test2() {
    vector<int> vec = {3, 2, 4, 5, 6, 6, 7, 8, 4, 3};
    priority_queue<int> queue;
    for (size_t idx = 0; idx < vec.size(); queue.push(vec[idx++]));

    while (!queue.empty()) {
        cout << queue.top() << endl;
        queue.pop();
    }
}


void test3() {
    priority_queue<Point> priorityQueue;
    vector<Point> vec = {
            Point(1, 2),
            Point(2, 7),
            Point(1, 0),
            Point(-1, 0),
            Point(4, 9)
    };

    for (size_t idx = 0; idx < vec.size(); priorityQueue.push(vec[idx++]));

    while (!priorityQueue.empty()) {
        cout << priorityQueue.top() << endl;
        priorityQueue.pop();
    }
}


int main() {
    test3();
    return 0;
}
